package com.ugoodtech.mdcc.core.model.mapper;

import com.ugoodtech.mdcc.core.model.entity.Departments;
import com.ugoodtech.mdcc.core.model.entity.DepartmentsExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface DepartmentsMapper {
    @SelectProvider(type=DepartmentsSqlProvider.class, method="countByExample")
    int countByExample(DepartmentsExample example);

    @DeleteProvider(type=DepartmentsSqlProvider.class, method="deleteByExample")
    int deleteByExample(DepartmentsExample example);

    @Delete({
        "delete from departments",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into departments (id, creation_time, ",
        "deleted, enabled, update_time, ",
        "name, parentDepartmentId, ",
        "serialNumber, user_leader_id, ",
        "parent_id, type)",
        "values (#{id,jdbcType=BIGINT}, #{creationTime,jdbcType=TIMESTAMP}, ",
        "#{deleted,jdbcType=BIT}, #{enabled,jdbcType=BIT}, #{updateTime,jdbcType=TIMESTAMP}, ",
        "#{name,jdbcType=VARCHAR}, #{parentdepartmentid,jdbcType=BIGINT}, ",
        "#{serialnumber,jdbcType=VARCHAR}, #{userLeaderId,jdbcType=BIGINT}, ",
        "#{parentId,jdbcType=BIGINT}, #{type,jdbcType=INTEGER})"
    })
    int insert(Departments record);

    @InsertProvider(type=DepartmentsSqlProvider.class, method="insertSelective")
    int insertSelective(Departments record);

    @SelectProvider(type=DepartmentsSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="creation_time", property="creationTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="deleted", property="deleted", jdbcType=JdbcType.BIT),
        @Result(column="enabled", property="enabled", jdbcType=JdbcType.BIT),
        @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="parentDepartmentId", property="parentdepartmentid", jdbcType=JdbcType.BIGINT),
        @Result(column="serialNumber", property="serialnumber", jdbcType=JdbcType.VARCHAR),
        @Result(column="user_leader_id", property="userLeaderId", jdbcType=JdbcType.BIGINT),
        @Result(column="parent_id", property="parentId", jdbcType=JdbcType.BIGINT),
        @Result(column="type", property="type", jdbcType=JdbcType.INTEGER)
    })
    List<Departments> selectByExample(DepartmentsExample example);

    @Select({
        "select",
        "id, creation_time, deleted, enabled, update_time, name, parentDepartmentId, ",
        "serialNumber, user_leader_id, parent_id, type",
        "from departments",
        "where id = #{id,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="creation_time", property="creationTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="deleted", property="deleted", jdbcType=JdbcType.BIT),
        @Result(column="enabled", property="enabled", jdbcType=JdbcType.BIT),
        @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="parentDepartmentId", property="parentdepartmentid", jdbcType=JdbcType.BIGINT),
        @Result(column="serialNumber", property="serialnumber", jdbcType=JdbcType.VARCHAR),
        @Result(column="user_leader_id", property="userLeaderId", jdbcType=JdbcType.BIGINT),
        @Result(column="parent_id", property="parentId", jdbcType=JdbcType.BIGINT),
        @Result(column="type", property="type", jdbcType=JdbcType.INTEGER)
    })
    Departments selectByPrimaryKey(Long id);

    @UpdateProvider(type=DepartmentsSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") Departments record, @Param("example") DepartmentsExample example);

    @UpdateProvider(type=DepartmentsSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") Departments record, @Param("example") DepartmentsExample example);

    @UpdateProvider(type=DepartmentsSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Departments record);

    @Update({
        "update departments",
        "set creation_time = #{creationTime,jdbcType=TIMESTAMP},",
          "deleted = #{deleted,jdbcType=BIT},",
          "enabled = #{enabled,jdbcType=BIT},",
          "update_time = #{updateTime,jdbcType=TIMESTAMP},",
          "name = #{name,jdbcType=VARCHAR},",
          "parentDepartmentId = #{parentdepartmentid,jdbcType=BIGINT},",
          "serialNumber = #{serialnumber,jdbcType=VARCHAR},",
          "user_leader_id = #{userLeaderId,jdbcType=BIGINT},",
          "parent_id = #{parentId,jdbcType=BIGINT},",
          "type = #{type,jdbcType=INTEGER}",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(Departments record);
}